package com.example4.test3;

/**
 * @Auther: shiquan
 * @Date: 2024/10/15 - 10 - 15 -22:25
 */
public class GoodsTest {
    //需求 创建三个商品对象  并且把对象存到数组里面
    public static void main(String[] args) {
        //创建一个数组
        Goods[] arr = new Goods[3];
        // 创建商品对象
        Goods g1 = new Goods("1","华为",1888.8,100);
        Goods g2 = new Goods("2","小米",2000.9,200);
        Goods g3 = new Goods("3","小科",3000.8,300);


        //把商品对象放到数组里面
        arr[0] = g1;
        arr[1] =g2;
        arr[2]=g3;
        //4 遍历 i表示索引
        for (int i = 0; i < arr.length; i++) {
            //变量goods记录
            Goods goods =arr[i];
            System.out.println(goods.getId()+","+goods.getName()+","+goods.getPrice()+","+goods.getCount());


        }

    }
}
